<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE BangPatterns #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-4"></span><span class="hs-comment">--</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- Fast write-buffered Handles</span><span>
</span><span id="line-6"></span><span class="hs-comment">--</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- (c) The University of Glasgow 2005-2006</span><span>
</span><span id="line-8"></span><span class="hs-comment">--</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- This is a simple abstraction over Handles that offers very fast write</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- buffering, but without the thread safety that Handles provide.  It's used</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- to save time in GHC.Utils.Ppr.printDoc.</span><span>
</span><span id="line-12"></span><span class="hs-comment">--</span><span>
</span><span id="line-13"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-14"></span><span>
</span><span id="line-15"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Utils.BufHandle</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier">BufHandle</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>        </span><span class="annot"><a href="GHC.Utils.BufHandle.html#newBufHandle"><span class="hs-identifier">newBufHandle</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>        </span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutChar"><span class="hs-identifier">bPutChar</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>        </span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutStr"><span class="hs-identifier">bPutStr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutFS"><span class="hs-identifier">bPutFS</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutFZS"><span class="hs-identifier">bPutFZS</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutPtrString"><span class="hs-identifier">bPutPtrString</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-23"></span><span>        </span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutReplicate"><span class="hs-identifier">bPutReplicate</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>        </span><span class="annot"><a href="GHC.Utils.BufHandle.html#bFlush"><span class="hs-identifier">bFlush</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-25"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastMutInt.html"><span class="hs-identifier">GHC.Data.FastMutInt</span></a></span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier">when</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.html#"><span class="hs-identifier">Data.ByteString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier">ByteString</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Unsafe.html#"><span class="hs-identifier">Data.ByteString.Unsafe</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">BS</span></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Char.html#"><span class="hs-identifier">Data.Char</span></a></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier">ord</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.html#"><span class="hs-identifier">Foreign</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.String.html#"><span class="hs-identifier">Foreign.C.String</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/System.IO.html#"><span class="hs-identifier">System.IO</span></a></span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-41"></span><span>
</span><span id="line-42"></span><span class="hs-keyword">data</span><span> </span><span id="BufHandle"><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-var">BufHandle</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="BufHandle"><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-var">BufHandle</span></a></span></span><span> </span><span class="hs-pragma">{-#UNPACK</span><span class="hs-pragma">#-}</span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-43"></span><span>                           </span><span class="hs-pragma">{-#UNPACK</span><span class="hs-pragma">#-}</span><span class="hs-glyph">!</span><span class="annot"><a href="GHC.Data.FastMutInt.html#FastMutInt"><span class="hs-identifier hs-type">FastMutInt</span></a></span><span>
</span><span id="line-44"></span><span>                           </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span class="annot"><a href="GHC.Utils.BufHandle.html#newBufHandle"><span class="hs-identifier hs-type">newBufHandle</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.Handle.Types.html#Handle"><span class="hs-identifier hs-type">Handle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span>
</span><span id="line-47"></span><span id="newBufHandle"><span class="annot"><span class="annottext">newBufHandle :: Handle -&gt; IO BufHandle
</span><a href="GHC.Utils.BufHandle.html#newBufHandle"><span class="hs-identifier hs-var hs-var">newBufHandle</span></a></span></span><span> </span><span id="local-6989586621680782707"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782707"><span class="hs-identifier hs-var">hdl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-48"></span><span>  </span><span id="local-6989586621680782706"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782706"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (Ptr Word8)
forall a. Int -&gt; IO (Ptr a)
</span><a href="../../base/src/Foreign.Marshal.Alloc.html#mallocBytes"><span class="hs-identifier hs-var">mallocBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span>
</span><span id="line-49"></span><span>  </span><span id="local-6989586621680782703"><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782703"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO FastMutInt
</span><a href="GHC.Data.FastMutInt.html#newFastMutInt"><span class="hs-identifier hs-var">newFastMutInt</span></a></span><span>
</span><span id="line-50"></span><span>  </span><span class="annot"><span class="annottext">FastMutInt -&gt; Int -&gt; IO ()
</span><a href="GHC.Data.FastMutInt.html#writeFastMutInt"><span class="hs-identifier hs-var">writeFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782703"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-51"></span><span>  </span><span class="annot"><span class="annottext">BufHandle -&gt; IO BufHandle
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8 -&gt; FastMutInt -&gt; Handle -&gt; BufHandle
</span><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-var">BufHandle</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782706"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782703"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782707"><span class="hs-identifier hs-var">hdl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-52"></span><span>
</span><span id="line-53"></span><span class="annot"><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-type">buf_size</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span>
</span><span id="line-54"></span><span id="buf_size"><span class="annot"><span class="annottext">buf_size :: Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var hs-var">buf_size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">8192</span></span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutChar"><span class="hs-identifier hs-type">bPutChar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-57"></span><span id="bPutChar"><span class="annot"><span class="annottext">bPutChar :: BufHandle -&gt; Char -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutChar"><span class="hs-identifier hs-var hs-var">bPutChar</span></a></span></span><span> </span><span id="local-6989586621680782700"><span class="annot"><span class="annottext">b :: BufHandle
</span><a href="#local-6989586621680782700"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span id="local-6989586621680782699"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782699"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span id="local-6989586621680782698"><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782698"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680782697"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782697"><span class="hs-identifier hs-var">hdl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680782696"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782696"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-58"></span><span>  </span><span id="local-6989586621680782695"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782695"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FastMutInt -&gt; IO Int
</span><a href="GHC.Data.FastMutInt.html#readFastMutInt"><span class="hs-identifier hs-var">readFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782698"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-59"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782695"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-60"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutBuf"><span class="hs-identifier hs-var">hPutBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782697"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782699"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span>
</span><span id="line-61"></span><span>                </span><span class="annot"><span class="annottext">FastMutInt -&gt; Int -&gt; IO ()
</span><a href="GHC.Data.FastMutInt.html#writeFastMutInt"><span class="hs-identifier hs-var">writeFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782698"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-62"></span><span>                </span><span class="annot"><span class="annottext">BufHandle -&gt; Char -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutChar"><span class="hs-identifier hs-var">bPutChar</span></a></span><span> </span><span class="annot"><span class="annottext">BufHandle
</span><a href="#local-6989586621680782700"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782696"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-63"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Word8 -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; a -&gt; IO ()
</span><a href="../../base/src/Foreign.Storable.html#pokeElemOff"><span class="hs-identifier hs-var">pokeElemOff</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782699"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782695"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Word8
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782696"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-64"></span><span>                </span><span class="annot"><span class="annottext">FastMutInt -&gt; Int -&gt; IO ()
</span><a href="GHC.Data.FastMutInt.html#writeFastMutInt"><span class="hs-identifier hs-var">writeFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782698"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782695"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-65"></span><span>
</span><span id="line-66"></span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutStr"><span class="hs-identifier hs-type">bPutStr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-67"></span><span id="bPutStr"><span class="annot"><span class="annottext">bPutStr :: BufHandle -&gt; String -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutStr"><span class="hs-identifier hs-var hs-var">bPutStr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span id="local-6989586621680782690"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782690"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span id="local-6989586621680782689"><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782689"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680782688"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782688"><span class="hs-identifier hs-var">hdl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680782687"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782687"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-68"></span><span>  </span><span id="local-6989586621680782686"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782686"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FastMutInt -&gt; IO Int
</span><a href="GHC.Data.FastMutInt.html#readFastMutInt"><span class="hs-identifier hs-var">readFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782689"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-69"></span><span>  </span><span class="annot"><span class="annottext">String -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621680782685"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782687"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782686"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-70"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680782685"><span class="annot"><span class="annottext">loop :: String -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621680782685"><span class="hs-identifier hs-var hs-var">loop</span></a></span></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;&quot;</span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680782673"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782673"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">FastMutInt -&gt; Int -&gt; IO ()
</span><a href="GHC.Data.FastMutInt.html#writeFastMutInt"><span class="hs-identifier hs-var">writeFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782689"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782673"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-71"></span><span>        </span><span class="annot"><a href="#local-6989586621680782685"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680782672"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782672"><span class="hs-identifier hs-var">c</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680782671"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782671"><span class="hs-identifier hs-var">cs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621680782670"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782670"><span class="hs-identifier hs-var">i</span></a></span></span><span>
</span><span id="line-72"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782670"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-73"></span><span>                </span><span class="annot"><span class="annottext">Handle -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutBuf"><span class="hs-identifier hs-var">hPutBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782688"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782690"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span>
</span><span id="line-74"></span><span>                </span><span class="annot"><span class="annottext">String -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621680782685"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782672"><span class="hs-identifier hs-var">c</span></a></span><span class="annot"><span class="annottext">Char -&gt; String -&gt; String
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782671"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-75"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-76"></span><span>                </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Word8 -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; Int -&gt; a -&gt; IO ()
</span><a href="../../base/src/Foreign.Storable.html#pokeElemOff"><span class="hs-identifier hs-var">pokeElemOff</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782690"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782670"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Word8
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782672"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-77"></span><span>                </span><span class="annot"><span class="annottext">String -&gt; Int -&gt; IO ()
</span><a href="#local-6989586621680782685"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621680782671"><span class="hs-identifier hs-var">cs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782670"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-78"></span><span>
</span><span id="line-79"></span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutFS"><span class="hs-identifier hs-type">bPutFS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastString"><span class="hs-identifier hs-type">FastString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-80"></span><span id="bPutFS"><span class="annot"><span class="annottext">bPutFS :: BufHandle -&gt; FastString -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutFS"><span class="hs-identifier hs-var hs-var">bPutFS</span></a></span></span><span> </span><span id="local-6989586621680782669"><span class="annot"><span class="annottext">BufHandle
</span><a href="#local-6989586621680782669"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680782668"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782668"><span class="hs-identifier hs-var">fs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BufHandle -&gt; ByteString -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutBS"><span class="hs-identifier hs-var">bPutBS</span></a></span><span> </span><span class="annot"><span class="annottext">BufHandle
</span><a href="#local-6989586621680782669"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">(ByteString -&gt; IO ()) -&gt; ByteString -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FastString -&gt; ByteString
</span><a href="GHC.Data.FastString.html#bytesFS"><span class="hs-identifier hs-var">bytesFS</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621680782668"><span class="hs-identifier hs-var">fs</span></a></span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutFZS"><span class="hs-identifier hs-type">bPutFZS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#FastZString"><span class="hs-identifier hs-type">FastZString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-83"></span><span id="bPutFZS"><span class="annot"><span class="annottext">bPutFZS :: BufHandle -&gt; FastZString -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutFZS"><span class="hs-identifier hs-var hs-var">bPutFZS</span></a></span></span><span> </span><span id="local-6989586621680782665"><span class="annot"><span class="annottext">BufHandle
</span><a href="#local-6989586621680782665"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680782664"><span class="annot"><span class="annottext">FastZString
</span><a href="#local-6989586621680782664"><span class="hs-identifier hs-var">fs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BufHandle -&gt; ByteString -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutBS"><span class="hs-identifier hs-var">bPutBS</span></a></span><span> </span><span class="annot"><span class="annottext">BufHandle
</span><a href="#local-6989586621680782665"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">(ByteString -&gt; IO ()) -&gt; ByteString -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">FastZString -&gt; ByteString
</span><a href="GHC.Data.FastString.html#fastZStringToByteString"><span class="hs-identifier hs-var">fastZStringToByteString</span></a></span><span> </span><span class="annot"><span class="annottext">FastZString
</span><a href="#local-6989586621680782664"><span class="hs-identifier hs-var">fs</span></a></span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutBS"><span class="hs-identifier hs-type">bPutBS</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span id="bPutBS"><span class="annot"><span class="annottext">bPutBS :: BufHandle -&gt; ByteString -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutBS"><span class="hs-identifier hs-var hs-var">bPutBS</span></a></span></span><span> </span><span id="local-6989586621680782662"><span class="annot"><span class="annottext">BufHandle
</span><a href="#local-6989586621680782662"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680782661"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680782661"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; (CStringLen -&gt; IO ()) -&gt; IO ()
forall a. ByteString -&gt; (CStringLen -&gt; IO a) -&gt; IO a
</span><a href="../../bytestring/src/Data.ByteString.Unsafe.html#unsafeUseAsCStringLen"><span class="hs-identifier hs-var">BS.unsafeUseAsCStringLen</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621680782661"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="annot"><span class="annottext">((CStringLen -&gt; IO ()) -&gt; IO ()) -&gt; (CStringLen -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">BufHandle -&gt; CStringLen -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutCStringLen"><span class="hs-identifier hs-var">bPutCStringLen</span></a></span><span> </span><span class="annot"><span class="annottext">BufHandle
</span><a href="#local-6989586621680782662"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutCStringLen"><span class="hs-identifier hs-type">bPutCStringLen</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.String.html#CStringLen"><span class="hs-identifier hs-type">CStringLen</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span id="bPutCStringLen"><span class="annot"><span class="annottext">bPutCStringLen :: BufHandle -&gt; CStringLen -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutCStringLen"><span class="hs-identifier hs-var hs-var">bPutCStringLen</span></a></span></span><span> </span><span id="local-6989586621680782658"><span class="annot"><span class="annottext">b :: BufHandle
</span><a href="#local-6989586621680782658"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span id="local-6989586621680782657"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782657"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span id="local-6989586621680782656"><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782656"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680782655"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782655"><span class="hs-identifier hs-var">hdl</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680782654"><span class="annot"><span class="annottext">cstr :: CStringLen
</span><a href="#local-6989586621680782654"><span class="hs-identifier hs-var">cstr</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621680782653"><span class="annot"><span class="annottext">Ptr CChar
</span><a href="#local-6989586621680782653"><span class="hs-identifier hs-var">ptr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680782652"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782652"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-90"></span><span>  </span><span id="local-6989586621680782651"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782651"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FastMutInt -&gt; IO Int
</span><a href="GHC.Data.FastMutInt.html#readFastMutInt"><span class="hs-identifier hs-var">readFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782656"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-91"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782651"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782652"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span>
</span><span id="line-92"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutBuf"><span class="hs-identifier hs-var">hPutBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782655"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782657"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782651"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-93"></span><span>                </span><span class="annot"><span class="annottext">FastMutInt -&gt; Int -&gt; IO ()
</span><a href="GHC.Data.FastMutInt.html#writeFastMutInt"><span class="hs-identifier hs-var">writeFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782656"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-94"></span><span>                </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782652"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-95"></span><span>                    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Ptr CChar -&gt; Int -&gt; IO ()
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutBuf"><span class="hs-identifier hs-var">hPutBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782655"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CChar
</span><a href="#local-6989586621680782653"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782652"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-96"></span><span>                    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">BufHandle -&gt; CStringLen -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutCStringLen"><span class="hs-identifier hs-var">bPutCStringLen</span></a></span><span> </span><span class="annot"><span class="annottext">BufHandle
</span><a href="#local-6989586621680782658"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">CStringLen
</span><a href="#local-6989586621680782654"><span class="hs-identifier hs-var">cstr</span></a></span><span>
</span><span id="line-97"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-98"></span><span>                </span><span class="annot"><span class="annottext">Ptr CChar -&gt; Ptr CChar -&gt; Int -&gt; IO ()
forall a. Ptr a -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/Foreign.Marshal.Utils.html#copyBytes"><span class="hs-identifier hs-var">copyBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782657"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr CChar
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782651"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr CChar
</span><a href="#local-6989586621680782653"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782652"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-99"></span><span>                </span><span class="annot"><span class="annottext">FastMutInt -&gt; Int -&gt; IO ()
</span><a href="GHC.Data.FastMutInt.html#writeFastMutInt"><span class="hs-identifier hs-var">writeFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782656"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782651"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782652"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span>
</span><span id="line-101"></span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutPtrString"><span class="hs-identifier hs-type">bPutPtrString</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html#PtrString"><span class="hs-identifier hs-type">PtrString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span id="bPutPtrString"><span class="annot"><span class="annottext">bPutPtrString :: BufHandle -&gt; PtrString -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutPtrString"><span class="hs-identifier hs-var hs-var">bPutPtrString</span></a></span></span><span> </span><span id="local-6989586621680782648"><span class="annot"><span class="annottext">b :: BufHandle
</span><a href="#local-6989586621680782648"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span id="local-6989586621680782647"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782647"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span id="local-6989586621680782646"><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782646"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680782645"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782645"><span class="hs-identifier hs-var">hdl</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680782644"><span class="annot"><span class="annottext">l :: PtrString
</span><a href="#local-6989586621680782644"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.FastString.html#PtrString"><span class="hs-identifier hs-type">PtrString</span></a></span><span> </span><span id="local-6989586621680782642"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782642"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621680782641"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782641"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PtrString
</span><a href="#local-6989586621680782644"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">PtrString -&gt; IO () -&gt; IO ()
</span><span class="hs-operator hs-var">`seq`</span></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-103"></span><span>  </span><span id="local-6989586621680782640"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782640"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FastMutInt -&gt; IO Int
</span><a href="GHC.Data.FastMutInt.html#readFastMutInt"><span class="hs-identifier hs-var">readFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782646"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-104"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782640"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782641"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span>
</span><span id="line-105"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutBuf"><span class="hs-identifier hs-var">hPutBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782645"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782647"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782640"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-106"></span><span>                </span><span class="annot"><span class="annottext">FastMutInt -&gt; Int -&gt; IO ()
</span><a href="GHC.Data.FastMutInt.html#writeFastMutInt"><span class="hs-identifier hs-var">writeFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782646"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>
</span><span id="line-107"></span><span>                </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782641"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-108"></span><span>                    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutBuf"><span class="hs-identifier hs-var">hPutBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782645"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782642"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782641"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-109"></span><span>                    </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">BufHandle -&gt; PtrString -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutPtrString"><span class="hs-identifier hs-var">bPutPtrString</span></a></span><span> </span><span class="annot"><span class="annottext">BufHandle
</span><a href="#local-6989586621680782648"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">PtrString
</span><a href="#local-6989586621680782644"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-110"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-111"></span><span>                </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
forall a. Ptr a -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/Foreign.Marshal.Utils.html#copyBytes"><span class="hs-identifier hs-var">copyBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782647"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782640"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782642"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782641"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-112"></span><span>                </span><span class="annot"><span class="annottext">FastMutInt -&gt; Int -&gt; IO ()
</span><a href="GHC.Data.FastMutInt.html#writeFastMutInt"><span class="hs-identifier hs-var">writeFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782646"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782640"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782641"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-113"></span><span>
</span><span id="line-114"></span><span class="hs-comment">-- | Replicate an 8-bit character</span><span>
</span><span id="line-115"></span><span class="annot"><a href="GHC.Utils.BufHandle.html#bPutReplicate"><span class="hs-identifier hs-type">bPutReplicate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-116"></span><span id="bPutReplicate"><span class="annot"><span class="annottext">bPutReplicate :: BufHandle -&gt; Int -&gt; Char -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bPutReplicate"><span class="hs-identifier hs-var hs-var">bPutReplicate</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span id="local-6989586621680782639"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782639"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span id="local-6989586621680782638"><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782638"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680782637"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782637"><span class="hs-identifier hs-var">hdl</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680782636"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782636"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span id="local-6989586621680782635"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782635"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-117"></span><span>  </span><span id="local-6989586621680782634"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782634"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FastMutInt -&gt; IO Int
</span><a href="GHC.Data.FastMutInt.html#readFastMutInt"><span class="hs-identifier hs-var">readFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782638"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-118"></span><span>  </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680782631"><span class="annot"><span class="annottext">oc :: Word8
</span><a href="#local-6989586621680782631"><span class="hs-identifier hs-var hs-var">oc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Word8
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621680782635"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-119"></span><span>  </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782634"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782636"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span>
</span><span id="line-120"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-121"></span><span>      </span><span class="annot"><span class="annottext">Ptr Any -&gt; Word8 -&gt; Int -&gt; IO ()
forall a. Ptr a -&gt; Word8 -&gt; Int -&gt; IO ()
</span><a href="../../base/src/Foreign.Marshal.Utils.html#fillBytes"><span class="hs-identifier hs-var">fillBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782639"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Any
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782634"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680782631"><span class="hs-identifier hs-var">oc</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782636"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-122"></span><span>      </span><span class="annot"><span class="annottext">FastMutInt -&gt; Int -&gt; IO ()
</span><a href="GHC.Data.FastMutInt.html#writeFastMutInt"><span class="hs-identifier hs-var">writeFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782638"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782634"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782636"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-123"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-124"></span><span>      </span><span class="hs-comment">-- flush the current buffer</span><span>
</span><span id="line-125"></span><span>      </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782634"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutBuf"><span class="hs-identifier hs-var">hPutBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782637"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782639"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782634"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-126"></span><span>      </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782636"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&lt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-127"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-128"></span><span>          </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Word8 -&gt; Int -&gt; IO ()
forall a. Ptr a -&gt; Word8 -&gt; Int -&gt; IO ()
</span><a href="../../base/src/Foreign.Marshal.Utils.html#fillBytes"><span class="hs-identifier hs-var">fillBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782639"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680782631"><span class="hs-identifier hs-var">oc</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782636"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-129"></span><span>          </span><span class="annot"><span class="annottext">FastMutInt -&gt; Int -&gt; IO ()
</span><a href="GHC.Data.FastMutInt.html#writeFastMutInt"><span class="hs-identifier hs-var">writeFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782638"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782636"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-130"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-131"></span><span>          </span><span class="hs-comment">-- fill a full buffer</span><span>
</span><span id="line-132"></span><span>          </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Word8 -&gt; Int -&gt; IO ()
forall a. Ptr a -&gt; Word8 -&gt; Int -&gt; IO ()
</span><a href="../../base/src/Foreign.Marshal.Utils.html#fillBytes"><span class="hs-identifier hs-var">fillBytes</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782639"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621680782631"><span class="hs-identifier hs-var">oc</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span>
</span><span id="line-133"></span><span>          </span><span class="hs-comment">-- flush it as many times as necessary</span><span>
</span><span id="line-134"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680782624"><span class="annot"><span class="annottext">go :: Int -&gt; IO ()
</span><a href="#local-6989586621680782624"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680782623"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782623"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782623"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-135"></span><span>                                       </span><span class="annot"><span class="annottext">Handle -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutBuf"><span class="hs-identifier hs-var">hPutBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782637"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782639"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span>
</span><span id="line-136"></span><span>                                       </span><span class="annot"><span class="annottext">Int -&gt; IO ()
</span><a href="#local-6989586621680782624"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782623"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="GHC.Utils.BufHandle.html#buf_size"><span class="hs-identifier hs-var">buf_size</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-137"></span><span>                   </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FastMutInt -&gt; Int -&gt; IO ()
</span><a href="GHC.Data.FastMutInt.html#writeFastMutInt"><span class="hs-identifier hs-var">writeFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782638"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782623"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-138"></span><span>          </span><span class="annot"><span class="annottext">Int -&gt; IO ()
</span><a href="#local-6989586621680782624"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782636"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-139"></span><span>
</span><span id="line-140"></span><span class="annot"><a href="GHC.Utils.BufHandle.html#bFlush"><span class="hs-identifier hs-type">bFlush</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-141"></span><span id="bFlush"><span class="annot"><span class="annottext">bFlush :: BufHandle -&gt; IO ()
</span><a href="GHC.Utils.BufHandle.html#bFlush"><span class="hs-identifier hs-var hs-var">bFlush</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.BufHandle.html#BufHandle"><span class="hs-identifier hs-type">BufHandle</span></a></span><span> </span><span id="local-6989586621680782622"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782622"><span class="hs-identifier hs-var">buf</span></a></span></span><span> </span><span id="local-6989586621680782621"><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782621"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span id="local-6989586621680782620"><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782620"><span class="hs-identifier hs-var">hdl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-142"></span><span>  </span><span id="local-6989586621680782619"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782619"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FastMutInt -&gt; IO Int
</span><a href="GHC.Data.FastMutInt.html#readFastMutInt"><span class="hs-identifier hs-var">readFastMutInt</span></a></span><span> </span><span class="annot"><span class="annottext">FastMutInt
</span><a href="#local-6989586621680782621"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-143"></span><span>  </span><span class="annot"><span class="annottext">Bool -&gt; IO () -&gt; IO ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782619"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO () -&gt; IO ()) -&gt; IO () -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Handle -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
forall a. Handle -&gt; Ptr a -&gt; Int -&gt; IO ()
</span><a href="../../base/src/GHC.IO.Handle.Text.html#hPutBuf"><span class="hs-identifier hs-var">hPutBuf</span></a></span><span> </span><span class="annot"><span class="annottext">Handle
</span><a href="#local-6989586621680782620"><span class="hs-identifier hs-var">hdl</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782622"><span class="hs-identifier hs-var">buf</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621680782619"><span class="hs-identifier hs-var">i</span></a></span><span>
</span><span id="line-144"></span><span>  </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO ()
forall a. Ptr a -&gt; IO ()
</span><a href="../../base/src/Foreign.Marshal.Alloc.html#free"><span class="hs-identifier hs-var">free</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621680782622"><span class="hs-identifier hs-var">buf</span></a></span><span>
</span><span id="line-145"></span><span>  </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-146"></span></pre></body></html>